//===============================================================================
// Microsoft patterns & practices
// Web Client Software Factory
//===============================================================================
// Copyright � Microsoft Corporation.  All rights reserved.
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY
// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT
// LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
// FITNESS FOR A PARTICULAR PURPOSE.
//===============================================================================
// The example companies, organizations, products, domain names,
// e-mail addresses, logos, people, places, and events depicted
// herein are fictitious.  No association with any real company,
// organization, product, domain name, email address, logo, person,
// places, or events is intended or should be inferred.
//===============================================================================

using System;

using Microsoft.Practices.CompositeWeb.Web.UI;
using Microsoft.Practices.ObjectBuilder;

using MVPComposibility.ContactManager.Views;

using MVPComposibility.ContactManager.Views.ContactDetails;
using MVPComposibility.ContactManager.Views.ContactList;

namespace WebApplication.ContactManager
{
	public partial class PopupEditor : Page, IPopupEditorView
	{
		private PopupEditorPresenter _presenter;
		private ListDetailsMediator _mediator;

		protected void Page_Load(object sender, EventArgs e)
		{
			if (!IsPostBack)
			{
				_presenter.OnViewInitialized();
			}
			_presenter.OnViewLoaded();

			_mediator.ListModel = contactList.Presenter.Model;
			_mediator.DetailsModel = ContactDetails.Presenter.Model;
			if (!IsPostBack)
			{
				_mediator.Initialize();
			}
			_mediator.Load();
		}

		[CreateNew]
		public PopupEditorPresenter Presenter
		{
			set
			{
				_presenter = value;
				_presenter.View = this;
			}
		}

		[CreateNew]
		public ListDetailsMediator Mediator
		{
			set
			{
				_mediator = value;
			}
		}

		#region IPopupEditorView Members

		public void ShowContactDetailsPopup()
		{
			DetailsPopUp.Show();
		}

		public void HideContactDetailsPopup()
		{
			DetailsPopUp.Hide();
		}

		public IContactListView ContactListView
		{
			get { return contactList; }
		}

		public IContactDetailsView ContactDetailsView
		{
			get { return ContactDetails; }
		}

		#endregion
	}
}